package com.zjcode.cassync.controller;

import com.alibaba.fastjson.JSONObject;
import com.zjcode.cassync.model.PreUsers;
import com.zjcode.cassync.service.PreUsersService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:SyncApiController
 * @功能：
 * @author：wlei
 * @日期：2023/2/6-12:03
 **/
@RestController
@Slf4j
@RequestMapping("/v1/sync/")
public class SyncApiController {

    @Autowired
    private PreUsersService preUsersService;

    @GetMapping("version")
    public JSONObject getVersion() {
        JSONObject result = new JSONObject();
        // 版本
        result.put("version", "1.0.0");
        // 作者
        result.put("author", "wlei");
        return result;
    }

    /**
     * 查询所有的用户
     * @return
     */
    @GetMapping("queryAllUsers")
    public JSONObject queryAllUsers(){
        log.info("queryAllUsers");
        List<PreUsers> preUsers = preUsersService.selectAll();
        JSONObject result = new JSONObject();
        result.put("data", preUsers);
        return result;
    }
}
